package com.adm.biz;

import java.util.HashMap;
import java.util.Map;

import org.yfsoft.comm.util.BizResult;

import com.adm.ctl.GlobalKey;
import com.adm.ctl.ResultType;
import com.adm.dao.CommonDao;

public class CommonService extends Service {

	private CommonDao dao = null;

	public void setDao( CommonDao dao) {
		this.dao = dao;
	}
	
	private BizResult data = null;
	
	
	public BizResult login(Map<String,String> input){
		Map<String,Object> map = new HashMap<String,Object>();
		map.putAll(input);
		this.data = this.dao.list("usr_userinfo", new String[]{"ui_username,ui_password"}, "ui_username = 'admin'", null,1, 0);
		this.setSionAttr("models", this.dao.list("sys_model",null,null,null,100,0).getData());
		BizResult rst = new BizResult().setCode("0");
		this.setSionAttr(GlobalKey.USER, this.data);
		rst.setType(String.valueOf(ResultType.JUMP));
		rst.setPage("main.jsp");
		return rst;
	}

	
	public BizResult logout(Map<String,String> input){
		this.setSionAttr(GlobalKey.USER, this.data);
		BizResult rst = new BizResult().setCode("0");
		this.unsetSion(GlobalKey.USER);
		rst.setType(String.valueOf(ResultType.JUMP));
		rst.setPage("login.jsp");
		return rst;
	}
}
